home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / osi / isode / dosisode / DOSISODE80.ZIP / ISODE8.WRK / UNIX / LIB / NTOHS.C < prev    next >
Encoding:
Text File  |  1992-02-18  |  646 b   |  39 lines

  1. unsigned long ntohl(x)
  2. unsigned long x;
  3. {
  4. return(( ((x) >> 24)& 0x000000ff ) | ( ((x) >> 8) & 0x0000ff00 ) |
  5.        ( ((x) << 8) & 0x00ff0000 ) | ( ((x) << 24)& 0xff000000 ));
  6. /*
  7. return(x);
  8. */
  9. }
  10.  
  11. unsigned short ntohs(x)
  12. unsigned short x;
  13. {
  14. return((((x) >> 8) | ((x) << 8)) & 0xffff);
  15. /*
  16. return(x);
  17. */
  18. }
  19.  
  20. unsigned long htonl(x)
  21. unsigned long x;
  22. {
  23.  
  24. return(( ((x) >> 24)& 0x000000ff ) | ( ((x) >> 8) & 0x0000ff00 ) |
  25.        ( ((x) << 8) & 0x00ff0000 ) | ( ((x) << 24)& 0xff000000 ));
  26. /*
  27. return(x);
  28. */
  29. }
  30.  
  31. unsigned short htons(x)
  32. unsigned short x;
  33. {
  34. return((((x) >> 8) | ((x) << 8)) & 0xffff);
  35. /*
  36. return(x);
  37. */
  38. }
  39.